<html>
<head><meta charset="utf-8"><title>New Index trait? · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/New.20Index.20trait.3F.html">New Index trait?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208467843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/New%20Index%20trait%3F/near/208467843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Pham <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/New.20Index.20trait.3F.html#208467843">(Aug 30 2020 at 04:25)</a>:</h4>
<p>Hello, new here. Is there any interest in an Index trait that returns values?  I've been wanting this for some FFI code recently. Was told that here was the best place to ask about substantial feature requests.</p>



<a name="208468525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/New%20Index%20trait%3F/near/208468525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/New.20Index.20trait.3F.html#208468525">(Aug 30 2020 at 04:48)</a>:</h4>
<p>as opposed to <a href="https://doc.rust-lang.org/std/ops/trait.Index.html">https://doc.rust-lang.org/std/ops/trait.Index.html</a> ?</p>



<a name="208468931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/New%20Index%20trait%3F/near/208468931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/New.20Index.20trait.3F.html#208468931">(Aug 30 2020 at 05:04)</a>:</h4>
<p>I believe there's an existing <a href="https://github.com/rust-lang/rfcs/pull/2953">RFC</a> for that</p>



<a name="208471434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/New%20Index%20trait%3F/near/208471434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/New.20Index.20trait.3F.html#208471434">(Aug 30 2020 at 06:33)</a>:</h4>
<p>oh, I see.</p>



<a name="208519635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/New%20Index%20trait%3F/near/208519635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Pham <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/New.20Index.20trait.3F.html#208519635">(Aug 31 2020 at 04:28)</a>:</h4>
<p>Nice! When will it be merged?</p>



<a name="208520167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/New%20Index%20trait%3F/near/208520167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/New.20Index.20trait.3F.html#208520167">(Aug 31 2020 at 04:44)</a>:</h4>
<p>Looking at the RFC, it appears that there was a lot of discussion but no conclusive answer and no progress in the past 1-2 months. I think this is possibly due to the fact that while it is nice to have these traits, it introduces unexpected complexity, while basically converting a method call from <code>value.fn(idx)</code> to <code>value[idx]</code>. If you have a really compelling use case it might be worthwhile to bring it up in the comments there</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>